package test15;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-11-28
 * Time: 9:43
 */
class MyThread extends Thread{
    private String who;
    public MyThread(String str){
        who=str;
    }

    @Override
    public void run() {
        for(int i=0;i<5;i++){
            try {
                sleep((long) (1000*Math.random()));
            } catch (InterruptedException e) {
                System.out.println(e.toString());
            };
        }
        System.out.println(who+"正在运行");
    }
}

public class Main3 {
    public static void main(String[] args) {
        MyThread you = new MyThread("你");
        MyThread she = new MyThread("她");
        you.start();
        try {
            you.join();
        } catch (InterruptedException e) {
        }
        she.start();
        try {
            she.join();
        } catch (InterruptedException e) {
        }
        System.out.println("主方法main()运行结束!");
    }
}